<template>
	<view >
		<view>
			<image class="Baner" src="https://static.bxscs.cn/pic/20240908/404d85be-09f9-48c9-bea5-7a72fce19bd1.png"  v-show="role == 2"></image>
			<image class="Baner" src="https://static.bxscs.cn/pic/20240908/43e10440-bbc8-402f-8d10-29fbc98d502b.png" v-show="role == 3"></image>
			<view class="btn" @click="index()" v-if="role == 2 || role == 3">进入</view>
		</view>
	</view>
</template>

<script>
import {
	userInfo,
} from '@/common/api/my';
export default {
	data() {
		return {
			role:0,
			monitorUser:null,
		}
	},
	onLoad() {
		if (this.$store.state.user.userInfo.token) {
			this.info()
		} else {
			uni.switchTab({
			  url: '/pages/index/index'
			});
		}
	},
	
	onHide() {
		// 清除定时器
		clearTimeout(this.monitorUser);
	},
	
	methods: {
		// 用户信息
		info() {
			userInfo({}).then(res => {
				if (res.code === 200) {
					this.role = res.data.role
					if(res.data.role == 2 || res.data.role == 3 ){
						this.monitorUser = setTimeout(() => {
							uni.switchTab({
							  url: '/pages/index/index'
							});
						}, 3000);
					}else{
						uni.switchTab({
						  url: '/pages/index/index'
						});
					}
				}
			})
		},
		
		index(){
			clearTimeout(this.monitorUser);
			uni.switchTab({
			  url: '/pages/index/index'
			});
		},
	}
}
</script>

<style lang="scss" scoped>

.Baner{
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 9;
}

.btn{
	width: 200rpx;
	height: 80rpx;
	border-radius: 10rpx;
	background:  #C11C2F;
	font-weight: 600;
	font-size: 28rpx;
	color: #fff;
	line-height: 80rpx;
	text-align: center;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 20vh;
	margin: 0 auto;
	z-index: 10;
}
</style>